import { TCrossDefenseUpgrade } from "../../../../../../Message/Db/Tables/TCrossDefenseUpgrade";
import { FilterConst } from "../../../../../component/gconst/FilterConst";
import { ToolTipsManager } from "../../../../../../com/mui/manager/ToolTipsManager";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { ObjCreate } from "../../../common/ObjCreate";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
type int = number;
//class CrossDefenceBuildMenuItem
    
    export  class CrossDefenceBuildMenuItem /* flash.display.Sprite */
    {
        constructor(arg1: TCrossDefenseUpgrade, arg2: int)
        {
            
            this._curFilters = [FilterConst.colorFilter];
            this._data = arg1;
            this._key = arg2;
            this.initView();
            this.addEventListener(flash.events.MouseEvent.CLICK, this.clickMeHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.mouseOverMeHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.mouseOutMeHandler);
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.removedHandler);
            return;
        }

        public removedHandler(arg1: Object /* flash.events.Event */): void
        {
            ToolTipsManager.unregister(this);
            return;
        }

        public get data(): TCrossDefenseUpgrade
        {
            return this._data;
        }

        public set enabled(arg1: Boolean)
        {
            this._enabled = arg1;
            if (arg1) 
            {
                this.buttonMode = true;
                this._curFilters = [];
            }
            else 
            {
                this.buttonMode = false;
                this._curFilters = [FilterConst.colorFilter];
            }
            this.filters = this._curFilters;
            return;
        }

        public set canBuildNum(arg1: int)
        {
            this._txtKey.text = arg1.toString();
            if (arg1 <= 0) 
            {
                this._txtKey.textColor = 16711680;
            }
            else 
            {
                this._txtKey.textColor = 16776960;
            }
            return;
        }

        protected initView(): void
        {
            var loc1=GlobalClass.getBitmap(ImagesConst.PackItemBg);
            addChildAt(loc1, 0);
            var loc2=new Object /* flash.display.Bitmap */();
            this.addChild(loc2);
            LoaderHelp.setBitmapdata(this._data.showIcon.toString() + ".jpg", loc2, 2, 2, 34, 34);
            this._txtKey = ObjCreate.createGTextField("", 0, 23, 36, 20, this);
            this._txtKey.textColor = 16776960;
            this._txtKey.mouseEnabled = false;
            this._txtKey.mouseWheelEnabled = false;
            var loc3=this._txtKey.defaultTextFormat;
            loc3.align = flash.text.TextFormatAlign.RIGHT;
            this._txtKey.defaultTextFormat = loc3;
            this._txtKey.text = this._key.toString();
            return;
        }

        protected clickMeHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this._enabled) 
            {
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.ReqCrossDefenceCopyStartBuild, this._data));
            return;
        }

        protected mouseOverMeHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.filters = [FilterConst.worldMapFilter].concat(this._curFilters);
            return;
        }

        protected mouseOutMeHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.filters = this._curFilters;
            return;
        }

        protected /* var */_data: TCrossDefenseUpgrade;

        protected /* var */_enabled: Boolean;

        protected /* var */_curFilters: Array<any>;

        protected /* var */_key: int;

        protected /* var */_txtKey: GTextFiled;
    }
